var _util = _interopRequireDefault(require("../../public/utils/util"));

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

Component({
    properties: {
        src: {
            type: String,
            observer: function(e) {
                var t = this.data, i = t.size, a = t.thumb, n = {
                    image: e
                };
                e && "false" !== e && (i && (n.image = _util.default.clipImage(e, i + "_1e_1c")), 
                a && (n.defaultImage = _util.default.clipImage(e, "100w_1e_1c")), this.$setData(n));
            }
        },
        mode: {
            type: String,
            value: "scaleToFill"
        },
        size: String,
        thumb: {
            type: Boolean,
            value: !1
        },
        margins: {
            type: Object,
            value: {}
        }
    },
    data: {
        loading: !1,
        hqLoading: !1,
        defaultImage: "https://7072-production-f72692-1257600323.tcb.qcloud.la/white.png"
    },
    ready: function() {},
    methods: {
        observerElem: function() {
            var e = this, t = this.data, i = t.margins, a = t.thumb;
            wx.lazyFetch({
                selector: ".image",
                scope: this,
                margins: i,
                handler: function() {
                    a ? e.$setData({
                        hqLoading: !0
                    }) : e.onComplete();
                }
            });
        },
        onComplete: function() {
            this.$setData({
                loading: !0,
                thumb: !1
            });
        },
        onLoad: function(e) {
            this.triggerEvent("load", e.detail, {});
        },
        onError: function(e) {
            this.triggerEvent("error", e.detail, {});
        }
    }
});